#ifndef __RENDER_QUEUE_H__
#define __RENDER_QUEUE_H__

#pragma once

#include "RenderObject.h"

namespace Nezha
{

	struct RenderQueueEntry
	{
		RenderQueHashVal HashValue;
		RenderObject* RObject;
		RenderPass* RPass;
	};

	/**
	FIXME
		Consider only forward shading currently.
	*/
	class GRAPHICS_ENTRY RenderQueue
	{
		friend class Renderer;
	public:
		enum SortType
		{
			ST_MATERIAL,
			ST_FAR2NEAR,
			ST_NEAR2FAR,
		};

		RenderQueue();
		RenderQueue(SortType st);
		virtual ~RenderQueue();

		void addRenderObject(RenderObject* ro);

		void clear();

		SortType getSortType() const
		{
			return mSortType;
		}

	protected:
		void sort();

		void draw();

		void setSortType(SortType st)
		{
			mSortType = st;
		}

	protected:
		u32 getStatesHash(RenderPass* pass);

		u32 getMaterialHash(RenderPass* pass);

		typedef PArray<RenderQueueEntry> QueueEntryList;

		QueueEntryList mQueueEntries;

		u32 mNumEntries;
		SortType mSortType;
	};

}//end namespace Nezha

#endif //end __RENDER_QUEUE_H__